package com.ruoyi.system.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.mybatis.core.page.PageQuery;
import com.ruoyi.common.mybatis.core.page.TableDataInfo;
import com.ruoyi.system.domain.TimeInterval;
import com.ruoyi.system.mapper.TimeIntervalMapper;
import com.ruoyi.system.service.TimeIntervalService;
import org.springframework.stereotype.Service;


/**
 * 时间间隔服务impl
 *
 * @author Administrator
 * @date 2023/03/13
 */
@Service
public class TimeIntervalServiceImpl extends ServiceImpl<TimeIntervalMapper, TimeInterval> implements TimeIntervalService {

    @Override
    public TableDataInfo<TimeInterval> pageTimeInterval(TimeInterval timeInterval, PageQuery pageQuery) {
        String timeIntervalName = timeInterval.getTimeIntervalName();
        return TableDataInfo.build(baseMapper.selectPage(pageQuery.build(), Wrappers.lambdaQuery(TimeInterval.class)
            .likeRight(StrUtil.isNotBlank(timeIntervalName), TimeInterval::getTimeIntervalName, timeIntervalName)));
    }
}
